﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace uVirtualWeb
{
    public class Export
    {
        public static void Excel(HttpResponse Response, System.Web.UI.WebControls.ListView Grid)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=YourFileName.xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.xls"; //"application/vnd.ms-excel"
            System.IO.StringWriter sw = new System.IO.StringWriter(); 
            HtmlTextWriter hw = new HtmlTextWriter(sw); 
            Grid.RenderControl(hw); 
            Response.Output.Write(sw.ToString()); 
            Response.Flush(); 
            Response.End();
        }
    }
}